﻿@{
    ViewBag.Title = "用户实物管理";
    ViewBag.PathToBtn = "/UserCard/List";
    ViewBag.TextBtn = "刷新";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                用户实物列表
            </div>
            <div class="panel-body">
                <div class="dataTable_wrapper">
                    <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                        <thead>
                            <tr>
                                <th>实物名称</th>
                                <th>券码</th>
                                <th>物流单号</th>
                                <th>物流公司</th>
                                <th>收货地址</th>
                                <th>核销时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody></tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="LogisticsModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="max-width: 600px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">添加物流信息</h4>
            </div>
            <div class="modal-body">
                <table>
                    <tr>
                        <td style="padding: 5px;"><span class="input-group-addon">快递公司：</span></td>
                        <td style="padding: 5px;"><input type="text" class="form-control" id="txtLogisticsCompany" style="width: 260px;" placeholder="请填写快递公司" /></td>
                    </tr>
                    <tr>
                        <td style="padding: 5px;"><span class="input-group-addon">快递单号：</span></td>
                        <td style="padding: 5px;"><input type="text" class="form-control" id="txtLogisticsCode" style="width: 260px;" placeholder="请填写快递单号" /></td>
                    </tr>
                    <tr>
                        <td style="padding: 5px;"><input type="hidden" id="hidPostRecordId" /></td>
                        <td style="padding: 5px;"><a href="javascript:;" id="btnDialogSave" class="btn btn-info" data-options="iconCls:'icon-ok'" style="float: right">确定</a></td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</div>
@section javascript{
    <script src="/Content/admin/dist/js/pagingHelper.js"> </script>
    <script type="text/javascript">
        var dataParams = {};
        var serverProcessPath = "/Physical/Listing";
        var showColumns = [
            { data: "CardName" },
            { data: "CardCode" },
            { data: "LogisticsNum" },
            { data: "LogisticsCompany" },
            { data: "ConsumerAddress" },
            { data: "ShowVerifyTime" },
        { data: "Action" }
        ];
        pagingHelper.Paging(serverProcessPath, dataParams, showColumns);


        $(function () {
            $("#btnDialogSave").click(function () {
                var logisticsCompany = $("#txtLogisticsCompany").val();
                var logisticsCode = $("#txtLogisticsCode").val();
                if (logisticsCompany == "") {
                    return alertify.alert('请填写快递公司！');
                }
                if (logisticsCode == "") {
                    return alertify.alert('请填写快递单号！');
                }
                savePostRecord($("#hidPostRecordId").val(), logisticsCompany, logisticsCode);
            });
        });
        function savePostRecord(id, logisticsCompany, logisticsCode) {
            alertify.okBtn("确定").cancelBtn("取消").confirm("确定执行此操作吗？（操作不可逆）", function () {
                var param = {
                    Id: id,
                    LogisticsCompany: logisticsCompany,
                    LogisticsNum: logisticsCode
                };
                $.post("/Physical/SavePostRecord", param, function (data) {
                    if (data.Status) {
                        alertify.alert("操作成功！");
                        location.reload();
                    } else {
                        alertify.alert(data.Message);
                    }
                });
                $('#divDialog').window('close');
            }, true);
        }

        function AddLogistics(id) {
            $("#hidPostRecordId").val(id);
        }
    </script>
}